﻿using RBAC_Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RBAC_Application.Repository.Interface
{
    public interface IPermissionRepository
    {
        // 查询
        /// <summary>
        /// 根据权限ID查询权限信息
        /// </summary>
        /// <param name="id">权限ID</param>
        /// <returns>权限对象</returns>
        Permission GetById(long id);  // 修改为long类型
        /// <summary>
        /// 获取所有权限信息
        /// </summary>
        /// <returns>权限列表</returns>
        List<Permission> GetAll();
        /// <summary>
        /// 根据关键字和模块名称查询权限
        /// </summary>
        /// <param name="keyword">关键字</param>
        /// <param name="module">模块名称</param>
        /// <returns>权限列表</returns>
        List<Permission> GetByCondition(string keyword, string module);
        /// <summary>
        /// 根据角色ID获取权限列表
        /// </summary>
        /// <param name="roleId">角色ID</param>
        /// <returns>权限列表</returns>
        List<Permission> GetPermissionsByRoleId(long roleId);  // 修改为long类型

        // 增删改
        /// <summary>
        /// 添加权限
        /// </summary>
        /// <param name="permission">权限对象</param>
        void Add(Permission permission);
        /// <summary>
        /// 更新权限
        /// </summary>
        /// <param name="permission">权限对象</param>
        void Update(Permission permission);
        /// <summary>
        /// 删除权限
        /// </summary>
        /// <param name="id">权限ID</param>
        void Delete(long id);  // 修改为long类型
        /// <summary>
        /// 判断权限名称是否已存在
        /// </summary>
        /// <param name="permissionName">权限名称</param>
        /// <returns>true表示已存在，false表示不存在</returns>
        bool Exists(string permissionName);

        // 角色权限关联
        /// <summary>
        /// 分配角色权限
        /// </summary>
        /// <param name="roleId">角色ID</param>
        /// <param name="permissionId">权限ID</param>
        void AssignRolePermission(long roleId, long permissionId);
        /// <summary>
        /// 移除角色权限
        /// </summary>
        /// <param name="roleId">角色ID</param>
        /// <param name="permissionId">权限ID</param>
        void RemoveRolePermission(long roleId, long permissionId);
        /// <summary>
        /// 获取角色权限列表
        /// </summary>
        /// <param name="roleId">角色ID</param>
        /// <returns>权限列表</returns>
        List<Permission> GetRolePermissions(long roleId);
    }
}
